﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WPFSLVstoDesigner.Utilities
{
    class test
    {
/* 
        XNamespace w = WordProcessingMLNamespace;
        XName r = w + "r";
        XName ins = w + "ins";
 
        using (OpenXmlDocument doc = new OpenXmlDocument(filename))
        {
            Relationship documentRelationship =
                (
                    from dr in doc.Relationships
                    where dr.RelationshipType == DocumentRelationshipType
                    select dr
                ).FirstOrDefault();
 
            Relationship stylesRelationship =
                (
                    from sr in documentRelationship.Relationships
                    where sr.RelationshipType == StylesRelationshipType
                    select sr
                ).FirstOrDefault();
 
            string defaultStyle = (string)(
                from style in stylesRelationship
                              .XDocument.Root.Elements(w + "style")
                where (string)style.Attribute(w + "type") == "paragraph" &&
                      (string)style.Attribute(w + "default") == "1"
                select style
            ).First().Attribute(w + "styleId");
 
            XDocument xDoc = documentRelationship.XDocument;
 
            // Find all paragraphs in the document.
            var paragraphs =
                from p in xDoc
                             .Root
                             .Element(w + "body")
                             .Descendants(w + "p")
                let styleNode = p
                                .Elements(w + "pPr")
                                .Elements(w + "pStyle")
                                .FirstOrDefault()
                select new
                {
                    ParagraphElement = p,
                    StyleName = styleNode != null ?
                        (string)styleNode.Attribute(w + "val") :
                        defaultStyle,
                    // in the following query, we need to select both
                    // the r and ins elements in order to assemble the text
                    // properly for paragraphs that have tracked changes.
                    Text = p
                           .Elements()
                           .Where(z => z.Name == r || z.Name == ins)
                           .Descendants(w + "t")
                           .StringConcatenate(element => (string)element)
                };
 
            Console.WriteLine("DefaultStyle: {0}", defaultStyle);
 
            foreach (var p in paragraphs)
            {
                Console.WriteLine("Style: {0}   Text: >{1}<",
                    p.StyleName.PadRight(16), p.Text);
            }
        }
    }
}
 
public static class LocalExtensions
{
    public static string StringConcatenate<T>(this IEnumerable<T> source,
        Func<T, string> func)
    {
        StringBuilder sb = new StringBuilder();
        foreach (T item in source)
            sb.Append(func(item));
        return sb.ToString();
    }
}

*/
    }
}
